package com.system.jfm.Components;
import java.awt.Color;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JTextField;
import javax.swing.*;
import java.awt.Graphics;

public class PlaceHolder implements FocusListener{
    private String hintText;
    private JTextField textField;
    public PlaceHolder(JTextField textField,String hintText) {
        this.hintText = hintText;
        this.textField = textField;
        textField.setText(hintText);
        textField.setForeground(Color.GRAY);
    }
            @Override
            public void focusGained(FocusEvent e) {
                String temp = textField.getText();
                if (temp.equals(hintText)){
                    textField.setText("");
                    textField.setForeground(Color.BLACK);
                }
            }
            @Override
            public void focusLost(FocusEvent e) {
                String temp=textField.getText();
                if (temp.equals("")){
                    textField.setForeground(Color.GRAY);
                    textField.setText(hintText);
                }
            }

    }
